{%for group in group_list%}

<div class="content-box column-{%cycle 'left' 'right'%}">


	<div class="content-box-header">
		<h3>{{group.name}}</h3>
	</div>
	<!-- End .content-box-header -->

	<div class="content-box-content">

		<div class="tab-content default-tab">

			<h4>成员信息</h4>
			<table>

				<thead>
					<tr>
						<th>学号</th>
						<th>姓名</th>
						<th>角色</th>
					</tr>

				</thead>

				<tfoot>
				{% if not user.group %}
					<tr>
						<td colspan="3">
							<div class="bulk-actions align-left">
								<a class="button join-group" name="{{group.id}}" href="javascript:void(0);">加入该小组</a>
							</div>
							<div class="clear"></div></td>
					</tr>
				{% endif %}
				</tfoot>

				<tbody>
				{%for user in group.users.all%}
					<tr>
						<td>{{user.student_id}}</td>
						<td>{{user.name}}</td>
						
						{% ifequal group.administrator.student_id  user.student_id %}
							<td><span style="color:red">组长</span></td>
						
						{% else %}
							<td>组员</td>
						{% endifequal %}
					
					</tr>
				{% endfor %}
				</tbody>

			</table>

		</div>
		<!-- End #tab3 -->

	</div>
	<!-- End .content-box-content -->

</div>
<!-- End .content-box -->
{%cycle '' '<div class="clear"></div><!-- End .clear -->'%}
{% endfor %}
<script type="text/javascript">
$.each($('.join-group'),function(index,obj){
	
	if($(obj).attr('name')!='')
		$(obj).bind('click',function(event)
				{
			
			Boxy.ask("您确定要加入该组吗", ['确定','取消'],function(val) {
				if(val=='确定')
					{
							$.get("join_group",
							{"group":$(obj).attr('name')},
							function(json)
							{
								if(json.error)
				    			{
									if(json.error_type=="GroupMemberFull")
										{
										Boxy.alert("小组人数已满，请选择其他的小组", function() {}, {title: '错误'});
										}
									else
				    				Boxy.alert("加入失败，请检查您的信息"+json.error_type, function() {}, {title: '错误'});
				    			}
				    			else
				    			{
				    				Boxy.alert("加入成功", function() {$('#main-content').load('my_group')}, {title: '成功'});
				    			}
							},
							"json"
							);
					}
			}, {title: '警告'});
			
		});

});
</script>